package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.Generalize;
import com.wude.guild.holder.GeneralizeHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wude01 on 2017/10/23.
 */

public class GeneralizeAdapter extends BaseAdapter {
    private List<Generalize> dataList = new ArrayList<>();
    private final Activity activity;

    public GeneralizeAdapter(Activity activity) {
        this.activity = activity;
    }

    @Override

    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        GeneralizeHolder holder;
        if (convertView == null) {
            holder = new GeneralizeHolder(activity);
        } else {
            holder = (GeneralizeHolder) convertView.getTag();
        }
        holder.setData(dataList.get(i), i, activity);
        return holder.getContentView();
    }

    public List<Generalize> getDataList() {
        return dataList;
    }

    public void setDataList(List<Generalize> dataList) {
        this.dataList = dataList;
        notifyDataSetChanged();
    }
}
